var a = getApp(), t = require("../../../../utils/themeSkin/skinBehavior");

Page({
    behaviors: [ t ],
    data: {
        mailLanguage: {},
        language: "",
        balance: 0,
        recharge: 0,
        transfer: 0,
        withdraw: 0,
        recharge_wx: 0,
        recharge_alipay: 0,
        withdrawToWechat: 0,
        withdrawToAlipay: 0,
        member_credit2: 0,
        balanceLang: "余额",
        ios_virtual_pay: !1,
        dataInfo: {},
        name: !1,
        Navlis: "day",
        nameOther: [ {
            img: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2FecologicalPoint%2Frangli%402x.png",
            title: "让利奖励",
            id: 1
        }, {
            img: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2FecologicalPoint%2Fjingxiaoshang%402x.png",
            title: "经销商奖励",
            id: 2
        }, {
            img: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images%2FecologicalPoint%2Fquyu%402x.png",
            title: "区域奖励",
            id: 3
        } ],
        point_statistics: "",
        ecologicalName: "生态积分",
        isBindIdcardShow: true,//是否绑定身份证
    },
    onLoad: function(a) {
        if ("cat" == a.name) return this.setData({
            name: a.name
        }), void this.ecological();
        this.getBalance();
        try {
            var t = JSON.parse(wx.getStorageSync("mailLanguage"));
            t && this.setData({
                mailLanguage: t
            });
        } catch (a) {
            console.log(a);
        }
        try {
            var e = wx.getStorageSync("ios_virtual_pay");
            e && this.setData({
                ios_virtual_pay: e
            });
        } catch (a) {
            console.log(a);
        }
        try {
            var o = wx.getStorageSync("yz_basic_info");
            o && (o = o.balance || "余额", this.setData({
                balanceLang: o
            }), wx.setNavigationBarTitle({
                title: o
            }));
        } catch (a) {}
    },
    onReady: function() {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        });
    },
    onShow: function() {
      console.log('走了么')
      this.checkIdCard();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    tapNav: function(a) {
        console.log(a), this.setData({
            Navlis: a.currentTarget.dataset.key,
            point_statistics: []
        }), this.ecological();
    },
    ecological: function() {
        var t = this, e = a.getNetAddresss("plugin.ecological-point.frontend.controllers.page.index");
        a._getNetWork({
            url: e,
            data: {
                slot_type: this.data.Navlis
            },
            success: function(a) {
                var e = a.data;
                if (1 == e.result) {
                    console.log(e.data);
                    var o = wx.getStorageSync("yz_basic_info");
                    t.setData({
                        ecologicalName: o.ecological_point ? o.ecological_point : "生态积分",
                        balanceLang: o.ecological_point ? o.ecological_point : "生态积分"
                    }), wx.setNavigationBarTitle({
                        title: t.data.ecologicalName
                    }), wx.setNavigationBarColor({
                        frontColor: "#ffffff",
                        backgroundColor: t.data.themeBaseColor,
                        animation: {
                            duration: 400,
                            timingFunc: "easeIn"
                        }
                    }), t.setData({
                        dataInfo: e.data,
                        point_statistics: e.data.point_statistics
                    });
                } else wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    getBalance: function() {
        var t = this, e = a.getNetAddresss("finance.balance.index");
        a._getNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.setData({
                    dataInfo: e.data
                }), wx.setNavigationBarColor({
                    frontColor: "#ffffff",
                    backgroundColor: t.data.themeBaseColor,
                    animation: {
                        duration: 400,
                        timingFunc: "easeIn"
                    }
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    tourl: function(a) {
        var t = a.currentTarget.dataset.item;
        console.log(t,'tttttt')
        // return
        "Balance_recharge" == t ? this.chargeHandel() : "balance_transfer" == t ? this.transferHandel() : "balance_withdrawals" == t ? this.withdrawHandel() : "ecologicalPointOther" == t && wx.navigateTo({
            url: "/packageI/ecologicalPoint/ecologicalPointOther/ecologicalPointOther?status=" + a.currentTarget.dataset.status
        });
    },
    transformingTo: function(a) {
        var t = a.currentTarget.dataset.item;
        wx.navigateTo({
            url: "/packageI/ecologicalPoint/ecologicalPointAward/ecologicalPointAward?status=" + t.id
        });
    },
    godetailed: function() {
        wx.navigateTo({
            url: "/packageA/member/balance/detailed/detailed"
        });
    },
    godetailed_point: function() {
        wx.navigateTo({
            url: "/packageI/ecologicalPoint/ecologicalPointDetailed/ecologicalPointDetailed"
        });
    },
    chargeHandel: function() {
        if (this.data.ios_virtual_pay) return wx.showModal({
            title: "提示",
            content: "十分抱歉，由于相关规定，你暂时无法在这里充值！",
            confirmText: "知道了",
            showCancel: !1,
            success: function(a) {
                a.confirm && console.log(a);
            }
        }), !1;
        wx.navigateTo({
            url: "/packageA/member/balance/balance_recharge/balance_recharge"
        });
    },
    transferHandel: function() {
        wx.navigateTo({
            url: "/packageA/member/balance/balance_transfer/balance_transfer?balance=" + this.data.member_credit2
        });
    },
    withdrawHandel: function() {
      var e = this;
          var t = this, o = a.getNetAddresss("member.member.member-data");
          a._getNetWork({
              url: o,
              data: {
                  v: 2,
                  basic_info: 1
              },
              success: function (o) {
                  var r = o.data;
                  console.log(r.data.member.idcard,'rrrrrrrr')
                  if(1 === r.result) {
                    if(r.data.member.idcard != ""){
                      wx.navigateTo({
                        url: "/packageA/member/balance/balance_withdrawals/balance_withdrawals"
                    });
                    }else {
                      wx.navigateTo({
                        url: "/packageA/member/balance/idCard/idCard"
                    });
                    }
                  }
                  
              }
            })
        
    },
    checkIdCard: function() {
      var e = this;
          var t = this, o = a.getNetAddresss("member.member.member-data");
          a._getNetWork({
              url: o,
              data: {
                  v: 2,
                  basic_info: 1
              },
              success: function (o) {
                  var r = o.data;
                  console.log(r.data.member.idcard,'rrrrrrrr')
                  if(1 === r.result) {
                    if(r.data.member.idcard != ""){
                      e.setData({
                        isBindIdcardShow: false
                      })
                    }else {
                      e.setData({
                        isBindIdcardShow: true
                      })
                    }
                  }
                  
              }
            })
        
    },
    tobindIdcard(){
      wx.navigateTo({
        url: "/packageA/member/balance/idCard/idCard"
    });
    },
    transformingLoveV: function() {
        wx.navigateTo({
            url: "/packageA/member/balance/transformLoveV/transformLoveV"
        });
    }
});